package xiwei;

import entity.User;
import dao.UserDao;
import java.io.IOException;
import java.util.List;

public class CrudApp
{
    public static void main( String[] args ) throws IOException {
        UserDao userDao = new UserDao();
        System.out.println("初始数据");
        List<User> users = userDao.getAllUser();
        for(User temp: users) {
            System.out.println(temp);
        }
        User user = userDao.getUserById(1);
        user.setName("zhanglong");
        userDao.updateUser(user);
        System.out.println("\nupdate后的数据");
        users = userDao.getAllUser();
        for(User temp: users) {
            System.out.println(temp);
        }
        user = new User();
        user.setName("xinxin");
        user.setComment("girl friend");
        userDao.insertUser(user);
        System.out.println("\nisnert 后的数据");
        users = userDao.getAllUser();
        for(User temp: users) {
            System.out.println(temp);
        }
        user = userDao.getUserById(5);
        userDao.deleteUser(user);
        System.out.println("\ndelete 后的数据");
        users = userDao.getAllUser();
        for(User temp: users) {
            System.out.println(temp);
        }
    }
}
